package com.see.server.command;

import java.util.HashMap;

import com.see.domain.MessegeParser;
import com.see.domain.Protocol;
import com.see.exception.MessegeFeedException;
import com.see.server.SocketConnection;
import com.see.servise.SEEServise;


public class CommandHandler {
	

	 private SEEServise seeService;
	 private SocketConnection socketConnection;

     public CommandHandler(SEEServise seeService, SocketConnection socketConnection) {
    	 this.seeService = seeService;
    	 this.socketConnection = socketConnection;
     }
     
     public Command createCommand(HashMap<String, String> paramMap) throws MessegeFeedException {
             String cmd;
             cmd = paramMap.get(MessegeParser.MsgFields.TYPEMSG.name());
             if(cmd == null)
            	 throw new MessegeFeedException(Protocol.errormsg(Protocol.ERROR_FIELD, ""));
             switch(cmd) {
                     case Protocol.LOGIN_FIELD:
                             return new LoginCommand(socketConnection, paramMap);
                     case Protocol.SENDORDED_FIELD:
                             return new SendOrderCommand(socketConnection, paramMap);
                     case Protocol.CLOSE_FIELD:
                             return new CloseCommand(socketConnection, paramMap);
                     default:
                             return new UnknownCommand();
             }
     }
     
   
     
}
